/*
 *          AccumDirLight.glsl
 *
 *    light must be sent in view-space
 */

//------------------------------------------------------------------------------


-- Vertex


// IN
layout(location = 0) in vec4 inPosition;

// OUT
out vec2 vTexCoord;

void main()
{
  vTexCoord.s = (gl_VertexID << 1) & 2;
  vTexCoord.t = gl_VertexID & 2;

  gl_Position = vec4( 2.0f*vTexCoord - 1.0f, 0.0f, 1.0f);
  //vEyeDirVS = vec3( 0.0f, 0.0f, 1.0f);
}


--

//------------------------------------------------------------------------------


-- Fragment

// IN
in vec2 vTexCoord;

// OUT
layout(location = 0) out vec4 fragColor; //fragLight

// UNIFORM
uniform sampler2D uNormalBuffer;
//uniform sampler2D uDepthBuffer;

uniform vec3 uLightColor = vec3( 1.0f );
uniform vec3 uLightDirVS = vec3( 0.5f, 1.0f, -0.5f);


void main()
{
  vec3 normal = texture( uNormalBuffer, vTexCoord).xyz;
       normal = normalize( normal );
       
  vec3 lightDir = normalize(uLightDirVS);

  
  // ~ simple tmp diffuse lighting model
  float diffuse = max( 0.0f, dot( normal, lightDir));
  vec3 ambientColor = vec3( 0.1f );
  
  fragColor = vec4( ambientColor + diffuse*uLightColor, 1.0f);
}

